﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Container : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string[] name = { "张三","李四" };
            string[] number = { "201702001","201703002" };
            for (int i=0;i<name.Length;i++)
            {
                TableRow row = new TableRow();
                TableCell cellName = new TableCell();
                TableCell cellNumber = new TableCell();
                cellName.Text = name[i];
                cellNumber.Text = number[i];
                TextBox tb = new TextBox();
                TableCell cellGrade = new TableCell();
                cellGrade.Controls.Add(tb);

                row.Cells.Add(cellName);
                row.Cells.Add(cellNumber);
                row.Cells.Add(cellGrade);
                Table1.Rows.Add(row);
            }
            TableRow rowFoot = new TableRow();
            rowFoot.TableSection = TableRowSection.TableFooter;
            TableCell cellStat = new TableCell();
            cellStat.ColumnSpan = 2;
            cellStat.Text = "统计：";
            cellStat.HorizontalAlign = HorizontalAlign.Right;
            TableCell cellTotal = new TableCell();
            cellTotal.Text = "共计" + name.Count() + "条消息";
            rowFoot.Cells.Add(cellStat);
            rowFoot.Cells.Add(cellTotal);
            Table1.Rows.Add(rowFoot);

            Panel1.Visible = true;
            Panel2.Visible = false;

        }

        Button btn = new Button();
        btn.ID = "BtnSubmit";
        btn.Text = "提交";
        btn.Click += BtnSubmit_Click;
        PlaceHolder1.Controls.Add(btn);

        TextBox tb1 = new TextBox();
        tb1.ID = "txtInput";
        PlaceHolder1.Controls.Add(tb1);
    }

    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        Label1.Text = "动态添加按钮响应";
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Panel1.Visible = false;
        Panel2.Visible = true;
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Panel2.Visible = false;
        Panel2.Visible = false;
        Label1.Text = Literal1.Text + Literal2.Text;
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        TextBox _tb = PlaceHolder1.FindControl("txtInput") as TextBox;
        Label1.Text = _tb.Text;

    }

    protected void LbtView1_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View1);
        
    }

    protected void LbtView2_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View2);
    }
}